package vn.edu.uit.chemistry.model;

import java.util.ArrayList;

import vn.edu.uit.chemistry.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class DanhSachBanBeAdapter extends BaseAdapter {

	Context ctx;
	LayoutInflater mInflater;
	ArrayList<ThongTinHocSinh> listDSGui = new ArrayList<ThongTinHocSinh>(); 

	public DanhSachBanBeAdapter(Context _ctx, ArrayList<ThongTinHocSinh> _listDSGui) {
		this.ctx = _ctx;
		this.mInflater = LayoutInflater.from(_ctx);
		this.listDSGui = _listDSGui;
	}

	public int getCount() {
		return listDSGui.size();
	}

	public Object getItem(int arg0) {
		return null;
	}

	public long getItemId(int arg0) {
		return 0;
	}

	public class HocSinhHolder {
		public ImageView imgIcon;
		public TextView tvHoTen;
		public TextView tvMSHS;
		public ImageView imgDiemDanh;
	}

	public View getView(int pos, View v, ViewGroup group) {
		HocSinhHolder holder;

		String mshs = listDSGui.get(pos).getMshs();
		String hoten = listDSGui.get(pos).getTenHS();

		if (v == null) {
			v = mInflater.inflate(R.layout.row_diem_danh, null);
			holder = new HocSinhHolder();
			holder.imgIcon = (ImageView) v.findViewById(R.id.imgView);
			holder.tvHoTen = (TextView) v.findViewById(R.id.tvHoTen);
			holder.tvMSHS = (TextView) v.findViewById(R.id.tvMSHS);
			holder.imgDiemDanh = (ImageView) v.findViewById(R.id.imgDiemDanh);

			v.setTag(holder);
		} else {
			holder = (HocSinhHolder) v.getTag();
		}

		holder.tvHoTen.setText("Họ tên: " + hoten);
		holder.tvMSHS.setText("MSHS: " + mshs);
		holder.imgDiemDanh.setVisibility(View.INVISIBLE);

		return v;
	}

}
